package user03.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import user03.mapper.TMenuMapper;
import user03.model.TMenu;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class TMenuService extends ServiceImpl<TMenuMapper, TMenu> {

    public List<String> selectUrlListByIds(List<Long> ids) {
        if (ids == null || ids.size() <= 0) {
            return null;
        }
        QueryWrapper<TMenu> wrapper = new QueryWrapper<>();
        wrapper.in("id", ids);
        List<TMenu> list = list(wrapper);
        if (list == null || list.size() <= 0) {
            return null;
        }
        List<String> urls = new ArrayList<>();
        for (TMenu tMenu : list) {
            urls.add(tMenu.getUrl());
        }
        return urls;
    }

}
